package net.lanelife.casino.caipiao.service;

import net.lanelife.casino.caipiao.entity.PaymentMerchant;
import net.lanelife.casino.caipiao.repository.api.IPaymentMerchantRepository;
import net.lanelife.casino.caipiao.service.api.IPaymentMerchantService;
import net.lanelife.casino.common.repository.support.GenericRepository;
import net.lanelife.casino.common.service.support.GenericService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PaymentMerchantService extends GenericService<PaymentMerchant, Integer> implements IPaymentMerchantService {
	
	@Autowired
	private IPaymentMerchantRepository repository;
	
	public PaymentMerchantService() {
		super(PaymentMerchant.class);
	}
	
	@Override
	protected GenericRepository<PaymentMerchant, Integer> getRepository() {
		return repository;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void update(Integer id, Boolean available) throws Exception {
		PaymentMerchant pm = repository.findOne(id);
		pm.setAvailable(available);
	}

}
